package com.fingard.dsp.bank.directbank.abc11;

import com.fingard.dsp.bank.directConfig.FtpSet;
import com.fingard.dsp.bank.directbank.DirectBase;
import com.fingard.net.FtpPortClient;
import com.fingard.net.FtpReceiver;

import java.io.IOException;

public class ABC11Base extends DirectBase {
    protected String getCharset() {
        return getBankConfig().getCharset("UTF-8");
    }

    public FtpReceiver sendToBank(String fullFilePath, String fileName, FtpSet ftpSet) {
        FtpReceiver ftpReceiver = null;
        FtpPortClient ftpPortClient = null;
        try {
            ftpPortClient = new FtpPortClient(ftpSet);
            WriteBankLogLn("本地文件路径:" + fullFilePath);
            WriteBankLogLn("FTP服务器文件路径:" + ftpSet.upDir);
            WriteBankLogLn2("FTP服务器文件上传地址:" + ftpSet.serverIP + ":" + ftpSet.port);
            //FTP设置成被动模式
            ftpPortClient.setLocalPassiveMode();
            ftpReceiver = ftpPortClient.uploadFile(fullFilePath, fileName);
        } catch (Exception e) {
            if (ftpPortClient != null) {
                try {
                    ftpPortClient.disconnect();
                } catch (IOException ie) {
                    e.printStackTrace();
                    WriteBankLogLn(ie);
                }
            }
        }
        return ftpReceiver;
    }
}
